package com.alibaba.nacos.controller.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: nacos-spring-cloud-example
 * @description: 服务提供者测试
 * @author: coderChen
 * @create: 2024-09-29 14:15
 **/

@RestController
public class TestController {

    @Value("${server.port}")
    String servicePort;

    @GetMapping("/echo/{str}")
    public String echo(@PathVariable String str) {
        return "provider is here   " + str;
    }

//    @GetMapping("/provider/openfeign")
//    public String hiOpenfeign(){
//        return "provider port is:" + servicePort;
//    }

    @GetMapping("/provider/timeOut")
    public String requestTimeOut() throws InterruptedException {
        Thread.sleep(10000);
        return "provider port is: " + servicePort;
    }

    @GetMapping("/provider/openfeign")
    public String hiOpenfeign() {
        // 创建一个较大的字符串，以确保数据足够大以触发压缩
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < 1000; i++) {
            builder.append("provider port is: ").append(servicePort).append("\n");
        }
        return builder.toString();
    }
}
